package fastDfs.core;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

@RequestMapping(value = "/api/download")
@RestController
@Api(value = "上传下载服务",description = "上传下载服务")
public class DownloadfeignController {


    @Autowired
    private Downloadfeign downloadfeign;



    /**
     * 文件上传
     * @return result
     */
    @ApiOperation("上传")
    @PostMapping(value = "/upload")
    public HashMap<String, Object> uploadImageByCover(MultipartFile file){
       return downloadfeign.uploadImageByCover(file);
    }

    /**
     * 文件删除
     * @param path
     * @return
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除")
    public HashMap<String, Object> delete(@RequestParam String path) {
        return downloadfeign.delete(path);
    }


    /**
     * 文件下载
     * @param url 路径
     * @return
     */
    @GetMapping("/download")
    @ApiOperation("下载")
    public void downLoad(@RequestParam String url, HttpServletResponse response) throws IOException {
       downloadfeign.downLoad(url,response);
    }


}
